package 面试真题;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Ali202 {
    static List<List<Integer>> ans = new ArrayList<>();
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        traceBack(1,n,k,new ArrayList<Integer>());
        for (int i = 0; i < ans.size(); i++) {
            for (int j = 0; j < ans.get(i).size(); j++) {
                System.out.print(ans.get(i).get(j));
                if(j<k-1){
                    System.out.print(" ");
                }
            }
            if(i<ans.size()-1){
                System.out.print("\n");
            }
        }
    }

    private static void traceBack(int index, int n, int k, List<Integer> list) {
        if(k==0){
            ans.add(new ArrayList<>(list));
        }
        for (int j = index; j <= n; j++) {
            list.add(j);
            traceBack(j+1,n,k-1,list);
            list.remove(list.size()-1);
        }
    }
}
